Imports System.Xml

Public NotInheritable Class XmlHelper

    Private Sub New()

    End Sub

    Public Shared Function XPathToString(ByRef xdoc As XmlDocument, ByVal xpath As String) As String
        Dim result As String = String.Empty

        Dim node As XmlNode = xdoc.SelectSingleNode(xpath)
        If Not node Is Nothing Then
            result = node.InnerText
        End If

        Return result
    End Function

    Public Shared Function XPathToInteger(ByRef xdoc As XmlDocument, ByVal xpath As String) As Decimal
        Dim result As Integer = 0

        Dim node As XmlNode = xdoc.SelectSingleNode(xpath)
        If Not node Is Nothing Then
            result = Integer.Parse(node.InnerText)
        End If

        Return result
    End Function

    Public Shared Function XPathToDecimal(ByRef xdoc As XmlDocument, ByVal xpath As String) As Decimal
        Dim result As Decimal = 0

        Dim node As XmlNode = xdoc.SelectSingleNode(xpath)
        If Not node Is Nothing Then
            result = Decimal.Parse(node.InnerText)
        End If

        Return result
    End Function

End Class